import {createStore,applyMiddleware} from 'redux'
import thunk from 'redux-thunk'
let initValue={
    list:[],
    add:[]
}
let reducer=(state=initValue,action)=>{
    let newState=JSON.parse(JSON.stringify(state))
    switch (action.type){
        case 'GET_LIST':
            newState.list=action.data
            return newState;
        case 'ADD':
            newState.add.push(action.item)
            return newState;
        default:
            return state
    }
}
export default createStore(reducer,applyMiddleware(thunk))